/******************************************************************************
*
* This file is part of FreeTrack (http://code.google.com/p/qtfreetrack).
* BY Willy Gardiol (willy@gardiol.org)
*
* FreeTrack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeTrack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar.  If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************/

#ifndef LAYERMAPCALIBRATE_H
#define LAYERMAPCALIBRATE_H

#include "IncFreeTrack.h"
#include "freetrackwidget.h"

class FTPushButton;
class LayerMap;

class LayerMapCalibrate : public FreeTrackWidget
{
    Q_OBJECT
public:
    explicit LayerMapCalibrate(LayerMap*m);
    ~LayerMapCalibrate();

    // Draw the map
    void paintEvent ( QPaintEvent * event );
    // Grab mouse to pan the map
    void mousePressEvent ( QMouseEvent * event );
    void mouseReleaseEvent ( QMouseEvent * event );
    void mouseMoveEvent ( QMouseEvent * event );

signals:
    // Emit when a point is set
    void pointChanged(int p, QPoint pt);

public slots:
    // update internal point when the user change it outside this widget
    void updatePoint(int p, QPoint pt);

private slots:
    void setPoint1();
    void setPoint2();
    void setPoint3();
    void zoomIn();
    void zoomOut();

private:
    FTPushButton * zoom_in;
    FTPushButton * zoom_out;
    FTPushButton* point1_button;
    FTPushButton* point2_button;
    FTPushButton* point3_button;
    qreal zoom_factor;

    LayerMap* map;

    QPoint point1;
    QPoint point2;
    QPoint point3;

    QPoint center;
    QPoint mouse_start;

    QPixmap point1_icon;
    QPixmap point2_icon;
    QPixmap point3_icon;

    QLayout* createHorizontal();
    QLayout* createVertical();
};



#endif // LAYERMAPCALIBRATE_H
